home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / inventor / noodle / NurbMaker.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.8 KB  |  123 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  |   Description:
  19.  |      Defines the NurbMaker class. Given a quadMesh,
  20.  |      a bunch of parameters, it creates a group node with a bunch 
  21.  |      of SoIndexedNurbsSurface nodes. These nodes will create a nurbs 
  22.  |      surface if placed after an SoCoordinate3 node with the number of
  23.  |      points specified by the QuadMesh node.
  24.  |   
  25.  |      Note that you only need to look at the SoCoordinate3 node if 
  26.  |      you need to figure out whether edges match for wraparound. 
  27.  |      Otherwise this is all strictly 'topological'
  28.  |
  29.  |   Author(s)          : Paul Isaacs
  30.  |
  31. */
  32.  
  33. #ifndef _NURB_MAKER
  34. #define _NURB_MAKER
  35.  
  36. #include <Inventor/SbLinear.h>
  37.  
  38. extern class SoGroup;
  39. extern class SoCoordinate3;
  40. extern class SoQuadMesh;
  41. extern class SoIndexedNurbsSurface;
  42.  
  43. ////////////////////////////////////////////////////////////////////
  44. //    Class: NurbMaker 
  45. //
  46. ////////////////////////////////////////////////////////////////////
  47.  
  48. // C-api: prefix=NrbMkr
  49. class NurbMaker {
  50.  
  51.   public:
  52.     // Constructor, destructor
  53.     NurbMaker();
  54.     ~NurbMaker();
  55.  
  56.     // You can save me some work if you tell me whether the edges line up.
  57.     // If you're not wrapping it won't matter, but if you wrap it will.
  58.     SoGroup *createNurbsGroup(SbVec2s numQuadMeshDivisions, 
  59.                   SbVec2s doEdgesMatch );
  60.     SoGroup *createNurbsGroup(SoQuadMesh    *quadNode, 
  61.                   SoCoordinate3 *coordNode = NULL);
  62.  
  63.     // Default is FALSE
  64.     void   setFlipNormals(SbBool newFlip) {flipNormals = newFlip; };
  65.     SbBool isFlipNormals() { return flipNormals; };
  66.  
  67.     enum PatchType {
  68.     BEZIER,
  69.     CUBIC,
  70.     CUBIC_TO_EDGE,
  71.     USER_KNOTS
  72.     };
  73.     // Default is CUBIC_TO_EDGE
  74.     void  setPatchType(PatchType newPatchType);
  75.     PatchType getPatchType() { return patchType; }
  76.  
  77.     // Default is FALSE.
  78.     void setWraparound( SbVec2s newWrap )
  79.         { myWrap = newWrap; }
  80.     const SbVec2s &getWraparound() { return myWrap; }
  81.  
  82.     // Default is 1, for CUBIC
  83.     // This tells how many rows/columns to move over when we go to make
  84.     // the next sub-patch. Setting patchType to CUBIC changes it to 1, 
  85.     // and BEZIER to 3.
  86.     void setPatchShift( SbVec2s newShift )
  87.         { myShift = newShift; }
  88.     const SbVec2s &getPatchShift()
  89.         { return myShift; }
  90.  
  91.  
  92.     // Default is not to use the user knots, but standard ones for 
  93.     // BEZIER, CUBIC, or CUBIC_TO_EDGE 
  94.     void  setUserKnots( SbVec2s newNumKnots, 
  95.             float *newUKnots = NULL, float *newVKnots = NULL);
  96.     void  getUserKnots( SbVec2s &numKnots, float *UKnots, float *VKnots);
  97.     void setUserCurveOrder( SbVec2s newOrder ) { userOrder = newOrder; }
  98.     const SbVec2s &getUserCurveOrder() { return userOrder; }
  99.  
  100.   protected:
  101.  
  102.     void establishMyKnotParams();
  103.     void applyCubicToEdgeKnotVectors(int row, int col, 
  104.         SoIndexedNurbsSurface *myNurb, int lastRowToDo, int lastColToDo);
  105.   private:
  106.     SoGroup *nurbsGroup;
  107.  
  108.     PatchType patchType;
  109.     SbBool    flipNormals;
  110.  
  111.     SbVec2s  userNumKnots;
  112.     float   *userUKnots,  *userVKnots;
  113.     SbVec2s  userOrder;
  114.  
  115.     SbVec2s  myNumKnots;
  116.     SbVec2s  myOrder;
  117.     SbVec2s  myShift;
  118.     SbVec2s  myWrap;
  119.     float   *myUKnots,  *myVKnots;
  120. };
  121.  
  122. #endif /* _NURB_MAKER */
  123.